package com.yan.web;

import com.yan.bo.RequestInfo;
import com.yan.storage.MetricsStorage;
import org.springframework.util.StringUtils;

/**
 * @author yanheng
 * @data 2020/1/16 18:07
 */
public class MetricsCollector {
    private MetricsStorage metricsStorage;

    public MetricsCollector(MetricsStorage metricsStorage){
        this.metricsStorage = metricsStorage;
    }

    public void recordRequest(RequestInfo requestInfo){
        if (requestInfo == null || StringUtils.isEmpty(requestInfo.getApiName())){
            return;
        }
        metricsStorage.saveRequestInfo(requestInfo);
    }
}
